package com.llxz.blog.oss.controller;

import com.llxz.blog.oss.service.OssService;
import com.llxz.blog.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zzh
 * @description: 阿里云存储
 * date: 2021/9/3 16:48
 */

@RestController
@RequestMapping("/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    @RequestMapping("upload")
    public R uploadOssFile(MultipartFile file) {
        System.out.println("----------------");
        //获取上传文件  MultipartFile
        //返回上传到oss的路径
        String url = ossService.uploadAvatar(file);
        return R.ok().data("url",url);
    }

}
